#pragma once
#include "hardware_buffer.h"
#include <vector>

namespace krryn{
namespace view{
	enum element_type{
		type_float1,
		type_float2,
		type_float3,
		type_float4,
		type_short1,
		type_short2,
		type_short3,
		type_short4,
		type_argb,
		type_unsigned_byte4,
	};

	enum element_semantic{
		semantic_position,
		semantic_normal,
		semantic_diffuse,
		semantic_specular,
		semantic_texture_coordinates,
		semantic_bitangent,
		semantic_tangent,
	};

	struct vertex_element{
		size_t m_OffsetInBytes;
		element_type m_Element;
		element_semantic m_Semantic;
		unsigned short m_Index;
	};

	class vertex_format{
	public:
		vertex_format();

		int append_element(size_t a_OffsetInBytes, element_type a_Element, element_semantic a_Semantic, unsigned short a_Index = 0);
		const vertex_element &at(size_t a_Index);
		size_t size() const;
		int get_size_in_bytes() const;
	private:
		std::vector<vertex_element> m_Elements;
		int m_SizeInBytes;
	};

	class vertex_buffer : public hardware_buffer{
	public:
		vertex_buffer(size_t a_VertexSizeInBytes, size_t a_NumberOfVertices) 
			: hardware_buffer(a_VertexSizeInBytes * a_NumberOfVertices), 
			  m_VertexSizeInBytes(a_VertexSizeInBytes),
			  m_NumberOfVertices(a_NumberOfVertices) {}

		virtual ~vertex_buffer() {}

		size_t get_vertex_size_in_bytes() const { return m_VertexSizeInBytes; }
		size_t get_number_of_vertices() const { return m_NumberOfVertices; }

	private:
		size_t m_NumberOfVertices;
		size_t m_VertexSizeInBytes;
	};
}
}